I'm trying to understand what each line of this code does e.g. why is the $
there and what does it do?, can anyone help?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<head>
<script>
i=1;
$(document).ready(function(){
$("button").click(function(){
if(i==1){
document.getElementById("tf1").setAttribute("fill", "transparent");
document.getElementById("tf2") .setAttribute("fill", "yellow");
i=2;
}else if (i==2){
document.getElementById("tf2").setAttribute("fill", "transparent");
document.getElementById("tf3") .setAttribute("fill", "green");
i=3;
} else if(i==3) {
document.getElementById("tf3").setAttribute("fill", "transparent");
document.getElementById("tf1").setAttribute("fill", "red") ;
i=1;
}
});
});
</script>
Copyright Notice:Content Author:「luly」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37470466/what-does-this-function-do-and-what-does-it-mean